package com.linwen.excise.niuke._60;

import java.util.ArrayList;
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

/**
 * @author wlw
 * @date 2023/3/14 9:18 PM
 */
public class _41称砝码 {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int[] wight = new int[n];
        int[] count = new int[n];
        for (int i = 0; i < n; i++) {
            wight[i] = scanner.nextInt();
        }
        for (int i = 0; i < n; i++) {
            count[i] = scanner.nextInt();
        }
        Set<Integer> set = new HashSet<>();
        set.add(0);
        for (int i = 0; i < n; i++) {
            ArrayList<Integer> list = new ArrayList<>(set);
            for (int j = 1; j <= count[i]; j++) {// 个数 和下面list中所有的结果进行加
                for (int k = 0; k < list.size(); k++) {
                    set.add(list.get(k)+wight[i]*j);
                }
            }
        }
        System.out.println(set.size());

    }
}
